var member_id = shi = store_id = cart_id = '';
document.addEventListener('plusready',function(){
	member_id = plus.storage.getItem('id');
	store_id = plus.storage.getItem('store_id');
	ws = plus.webview.currentWebview();
	cart_id = ws.cart_id;
//	console.log(apiRoot+"?act=index&op=mobile");
//	window.setInterval(xianshi(cart_id),2000); 
	$.ajax({ 
		type:"post", 
		url:apiRoot+"?act=index&op=mobile",
		data:{cart_id:cart_id,store_id:store_id},
		dataType:'json',
		success:function(data){ 
			console.log(JSON.stringify(data));
			if(data.length > 0){
				var html = ''; 
				var html1 = html2 = html3 = html4 = html5 = '';
				var oDate = new Date(); //实例一个时间对象；
				var moth = oDate.getHours(); //获取系统时，
				shi = moth;
//				var fen = oDate.getMinutes(); //分
//				if(moth < 10){
//					var fen = '0'+moth; 
//				}
//				var mf = moth+':'+fen;	
				plus.storage.setItem('time',moth);
				if(moth >= 9 && moth < 12){
					html += '<a class="mui-control-item mui-active" href="#item1mobile">'+
								'<b>09:00<span>抢购中</span></b>'+							
							'</a>'+
							'<a class="mui-control-item" href="#item2mobile">'+
								'<b>12:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item3mobile">'+
								'<b>15:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item4mobile">'+
								'<b>18:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item5mobile">'+
								'<b>21:00<span>即将开始</span></b>'+
							'</a>';
				}else if(moth >= 12 && moth < 15){
					html += '<a class="mui-control-item" href="#item1mobile">'+
								'<b>09:00<span>已开抢</span></b>'+							
							'</a>'+
							'<a class="mui-control-item mui-active" href="#item2mobile">'+
								'<b>12:00<span>抢购中</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item3mobile">'+
								'<b>15:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item4mobile">'+
								'<b>18:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item5mobile">'+
								'<b>21:00<span>即将开始</span></b>'+
							'</a>';
				}else if(moth >= 15 && moth < 18){
					html += '<a class="mui-control-item" href="#item1mobile">'+
								'<b>09:00<span>已开抢</span></b>'+							
							'</a>'+
							'<a class="mui-control-item" href="#item2mobile">'+
								'<b>12:00<span>已开抢</span></b>'+
							'</a>'+
							'<a class="mui-control-item mui-active" href="#item3mobile">'+
								'<b>15:00<span>抢购中</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item4mobile">'+
								'<b>18:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item5mobile">'+
								'<b>21:00<span>即将开始</span></b>'+
							'</a>'; 
				}else if(moth >= 18 && moth < 21){
					html += '<a class="mui-control-item" href="#item1mobile">'+
								'<b>09:00<span>已开抢</span></b>'+							
							'</a>'+
							'<a class="mui-control-item" href="#item2mobile">'+
								'<b>12:00<span>已开抢</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item3mobile">'+
								'<b>15:00<span>已开抢</span></b>'+
							'</a>'+
							'<a class="mui-control-item mui-active" href="#item4mobile">'+
								'<b>18:00<span>抢购中</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item5mobile">'+
								'<b>21:00<span>即将开始</span></b>'+
							'</a>';
				}else if(moth >= 21 || moth < 2){
					html += '<a class="mui-control-item" href="#item1mobile">'+
								'<b>09:00<span>已开抢</span></b>'+							
							'</a>'+
							'<a class="mui-control-item" href="#item2mobile">'+
								'<b>12:00<span>已开抢</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item3mobile">'+
								'<b>15:00<span>已开抢</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item4mobile">'+
								'<b>18:00<span>已开抢</span></b>'+
							'</a>'+
							'<a class="mui-control-item mui-active" href="#item5mobile">'+
								'<b>21:00<span>抢购中</span></b>'+
							'</a>';
				}else if(moth >= 2 && moth < 9){
					html += '<a class="mui-control-item mui-active" href="#item1mobile">'+
								'<b>09:00<span>即将开始</span></b>'+							
							'</a>'+
							'<a class="mui-control-item" href="#item2mobile">'+
								'<b>12:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item3mobile">'+
								'<b>15:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item4mobile">'+
								'<b>18:00<span>即将开始</span></b>'+
							'</a>'+
							'<a class="mui-control-item" href="#item5mobile">'+
								'<b>21:00<span>即将开始</span></b>'+
							'</a>';
				}
				$('#sliderSegmentedControl').html(html);
				var statusa = statusb = statusc = statusd = statuse = 0;
				$.each(data, function(k,v) { 
					$.each(v.goods_details, function(key, value) {
						var Percentage = parseFloat(value.goods_salenum / value.goods_storage * 100).toFixed(0);
						if(value.zx[1] == '9:00'){
							statusa++;
							html1 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html1 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+  
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html1 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html1 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html1 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '12:00'){ 
							statusb++;
							html2 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html2 += '<button type="button" class="mui-btn mui-btn-danger">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html2 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html2 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html2 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '15:00'){ 
							statusc++;
							html3 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html3 += '<button type="button" class="mui-btn mui-btn-danger">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html3 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html3 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html3 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '18:00'){
							statusd++;
							html4 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html4 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html4 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html4 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html4 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '21:00'){
							statuse++;
							html5 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html5 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html5 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html5 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html5 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}
					})
					
				});
				var zt = '<div style="width: 80%;margin: 40px auto;text-align: center;font-size: 18px;">暂无数据...</div>';
				if(statusa > 0){
					$('#item1mobile').html(html1);
				}else{
					$('#item1mobile').html(zt);
				}
				if(statusb > 0){
					$('#item2mobile').html(html2);
				}else{
					$('#item2mobile').html(zt);
				}
				if(statusc > 0){
					$('#item3mobile').html(html3);
				}else{
					$('#item3mobile').html(zt);
				}
				if(statusd > 0){
					$('#item4mobile').html(html4);
				}else{
					$('#item4mobile').html(zt);
				}
				if(statuse > 0){
					$('#item5mobile').html(html5);   
				}else{
					$('#item5mobile').html(zt); 
				}
			}
			if(moth >= 9 && moth < 12){
							showItem(0);
			}else if(moth >= 12 && moth < 15){
							showItem(1);
				}else if(moth >= 15 && moth < 18){ 
							showItem(2);
				}else if(moth >= 18 && moth < 21){
							showItem(3);
				}else if(moth >= 21 || moth < 2){
							showItem(4);
				}else if(moth >= 2 && moth < 9){
							showItem(0);
				}
			//详情
			$('.Special').unbind('tap');
			$('.Special').on('tap',function(){
				var _this = $(this);
				var goodsid = _this.attr('data-id');
				var store_id = _this.attr('data-did');
				var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
				var webviewContent= plus.webview.create('./Special_details.html','Special_details.html',{},{goodsid:goodsid,store_id:store_id});//后台创建webview并打开show.html
				webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
			        nwaiting.close(); //新webview的载入完毕后关闭等待框
			        webviewContent.show("slide-in-right",20); //把新webview窗体显示出来，显示动画效果为速度200毫秒的右侧移入动画
			    }, false);
			})
		}, 
		error:function(e){
			toast('连接失败！');
		}
	});

	window.setInterval(function(){ 
		//xianshi(cart_id,shi);  
	}, 120000);  
},false); 


/*指定块显示*/
function showItem (n) {
	console.log(n);
	var muiSliderContent = $("#j_mui_slider_content .mui-control-content");
	muiSliderContent.eq(n).addClass("mui-active").siblings().removeClass("mui-active");
}

function xianshi(cart_id,shi){
	$.ajax({ 
		type:"post", 
		url:apiRoot+"?act=index&op=mobile",
		data:{cart_id:cart_id,store_id:store_id},
		dataType:'json',
		success:function(data){ 
//			console.log(JSON.stringify(data));
			if(data.length > 0){
				var html = ''; 
				var html1 = html2 = html3 = html4 = html5 = '';
				var oDate = new Date(); //实例一个时间对象；
				var moth = oDate.getHours(); //获取系统时，
//				var fen = oDate.getMinutes(); //分
//				if(moth < 10){
//					var fen = '0'+moth; 
//				}
//				var mf = moth+':'+fen;
				if(Number(moth) - Number(shi) >= 1){
					if(moth >= 9 && moth < 12){
						html += '<a class="mui-control-item mui-active" href="#item1mobile">'+
									'<b>09:00<span>抢购中</span></b>'+							
								'</a>'+
								'<a class="mui-control-item" href="#item2mobile">'+
									'<b>12:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item3mobile">'+
									'<b>15:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item4mobile">'+
									'<b>18:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item5mobile">'+
									'<b>21:00<span>即将开始</span></b>'+
								'</a>';
						$('#item1mobile').addClass('mui-active');
					}else if(moth >= 12 && moth < 15){
						html += '<a class="mui-control-item" href="#item1mobile">'+
									'<b>09:00<span>已开抢</span></b>'+							
								'</a>'+
								'<a class="mui-control-item mui-active" href="#item2mobile">'+
									'<b>12:00<span>抢购中</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item3mobile">'+
									'<b>15:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item4mobile">'+
									'<b>18:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item5mobile">'+
									'<b>21:00<span>即将开始</span></b>'+
								'</a>';
						$('#item2mobile').addClass('mui-active');
					}else if(moth >= 15 && moth < 18){
						html += '<a class="mui-control-item" href="#item1mobile">'+
									'<b>09:00<span>已开抢</span></b>'+							
								'</a>'+
								'<a class="mui-control-item" href="#item2mobile">'+
									'<b>12:00<span>已开抢</span></b>'+
								'</a>'+
								'<a class="mui-control-item mui-active" href="#item3mobile">'+
									'<b>15:00<span>抢购中</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item4mobile">'+
									'<b>18:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item5mobile">'+
									'<b>21:00<span>即将开始</span></b>'+
								'</a>';
						$('#item3mobile').addClass('mui-active');
					}else if(moth >= 18 && moth < 21){
						html += '<a class="mui-control-item" href="#item1mobile">'+
									'<b>09:00<span>已开抢</span></b>'+							
								'</a>'+
								'<a class="mui-control-item" href="#item2mobile">'+
									'<b>12:00<span>已开抢</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item3mobile">'+
									'<b>15:00<span>已开抢</span></b>'+
								'</a>'+
								'<a class="mui-control-item mui-active" href="#item4mobile">'+
									'<b>18:00<span>抢购中</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item5mobile">'+
									'<b>21:00<span>即将开始</span></b>'+
								'</a>';
						$('#item4mobile').addClass('mui-active');
					}else if(moth >= 21 || moth < 2){
						html += '<a class="mui-control-item" href="#item1mobile">'+
									'<b>09:00<span>已开抢</span></b>'+							
								'</a>'+
								'<a class="mui-control-item" href="#item2mobile">'+
									'<b>12:00<span>已开抢</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item3mobile">'+
									'<b>15:00<span>已开抢</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item4mobile">'+
									'<b>18:00<span>已开抢</span></b>'+
								'</a>'+
								'<a class="mui-control-item mui-active" href="#item5mobile">'+
									'<b>21:00<span>抢购中</span></b>'+
								'</a>';
						$('#item5mobile').addClass('mui-active');
					}else if(moth >= 2 && moth < 9){ 
						html += '<a class="mui-control-item mui-active" href="#item1mobile">'+
									'<b>09:00<span>即将开始</span></b>'+							
								'</a>'+
								'<a class="mui-control-item" href="#item2mobile">'+
									'<b>12:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item3mobile">'+
									'<b>15:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item4mobile">'+
									'<b>18:00<span>即将开始</span></b>'+
								'</a>'+
								'<a class="mui-control-item" href="#item5mobile">'+
									'<b>21:00<span>即将开始</span></b>'+
								'</a>';
						$('#item1mobile').addClass('mui-active'); 
					}
					$('#sliderSegmentedControl').html(html);
				}
				var statusa = statusb = statusc = statusd = statuse = 0;
				$.each(data, function(k,v) {
					$.each(v.goods_details, function(key, value) {
						var Percentage = parseFloat(value.goods_salenum / value.goods_storage * 100).toFixed(0);
						if(value.zx[1] == '9:00'){
							statusa++;
							html1 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html1 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html1 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html1 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html1 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '12:00'){
							statusb++;
							html2 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html2 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html2 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html2 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html2 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '15:00'){
							statusc++;
							html3 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' +  value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html3 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html3 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html3 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html3 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '18:00'){
							statusd++;
							html4 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html4 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html4 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html4 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html4 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}else if(value.zx[1] == '21:00'){
							statuse++;
							html5 += '<ul class="mui-table-view">'+
										'<li class="mui-table-view-cell mui-media">'+
											'<a href="javascript:;">'+
												'<img class="mui-media-object mui-pull-left" src="'+ pics + value.store_id + '/' + value.goods_image +'">'+
												'<div class="mui-media-body">'+
													'<div class="mui-ellipsis-2">'+ value.goods_name +'</div>'+
													'<div class="Pan">'+
														'<div class="mui-col-xs-4 mui-pull-left">'+
															'<b>￥'+ value.goods_price +'</b>'+
															'<s>￥'+ value.goods_marketprice +'</s>'+
														'</div>'+
														'<div class="mui-col-xs-8 mui-pull-left">';
														if(value.zx[1].substr(0,(value.zx[1].length - 3)) > moth){
															html5 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">即将开始</button>'+
																	'<div id="demo1">'+
																	'<span>已售'+ Percentage +'%</span>'+
																	'<div>'+
																		'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																	'</div>';
														}else{
															if(Percentage == 100){
																html5 += '<button type="button" class="mui-btn mui-btn-danger" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">已结束</button>'+
																			'<h5>已售'+ Percentage +'%</h5>';
																			
															}else{
																html5 += '<button type="button" class="mui-btn mui-btn-danger Special" data-id="'+ value.goods_id +'" data-did="'+ value.store_id +'">去抢购</button>'+
																		 '<div id="demo1">'+
																		'<span>已售'+ Percentage +'%</span>'+
																		'<div>'+
																			'<progress class="mui-progressbar mui-progressbar-warning" value="'+ Percentage +'"  max="100"></progress>'+
																		'</div>';
															}
														}
													html5 += '</div>'+
														'</div>'+
													'</div>'+
												'</div>'+
											'<a>'+
										'</li>'+
									'</ul>';
						}
					})
					
				});
				var zt = '<div style="width: 80%;margin: 40px auto;text-align: center;font-size: 18px;">暂无数据...</div>';
				if(statusa > 0){
					$('#item1mobile').html(html1);
				}else{
					$('#item1mobile').html(zt);
				}
				if(statusb > 0){
					$('#item2mobile').html(html2);
				}else{
					$('#item2mobile').html(zt);
				}
				if(statusc > 0){
					$('#item3mobile').html(html3);
				}else{
					$('#item3mobile').html(zt);
				}
				if(statusd > 0){
					$('#item4mobile').html(html4);
				}else{
					$('#item4mobile').html(zt);
				}
				if(statuse > 0){
					$('#item5mobile').html(html5);   
				}else{
					$('#item5mobile').html(zt); 
				}  
			}
			//详情
			$('.Special').unbind('tap');
			$('.Special').on('tap',function(){
				var _this = $(this);
				var goodsid = _this.attr('data-id');
				var store_id = _this.attr('data-did');
				var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
				var webviewContent= plus.webview.create('./goods_details.html','goods_details.html',{},{goodsid:goodsid,store_id:store_id});//后台创建webview并打开show.html
				webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
			        nwaiting.close(); //新webview的载入完毕后关闭等待框
			        webviewContent.show("slide-in-right",500); //把新webview窗体显示出来，显示动画效果为速度200毫秒的右侧移入动画
			    }, false);
			})
		}, 
		error:function(e){
			toast('连接失败！');
		}
	});
}
